package com.eos.freeect.common.dao.impl;

import java.sql.SQLException;
import java.util.List;

import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.HibernateCallback;

import com.eos.freeect.common.dao.LoginDao;
import com.eos.freeect.common.model.Announcement;
import com.eos.freeect.common.model.Login;

public class LoginDaoImpl extends CommDaoImpl implements LoginDao{
	
	@SuppressWarnings("unchecked")
    public List<Login> checkPWD(Login login) {
		return getHibernateTemplate().findByExample(login);
    }
	
	@SuppressWarnings("unchecked")
	public List<Announcement> getAnnouncementListMarquee() {
        List<Announcement> list = getHibernateTemplate().executeFind(new HibernateCallback() {
            public Object doInHibernate(Session session) throws HibernateException, SQLException {
                Query query = session.createQuery("from Announcement");
                return query.list();
            }
         });
		return list;
	}
	
	public List<Announcement> getAnnouncementList() {
        List<Announcement> list = getHibernateTemplate().executeFind(new HibernateCallback() {
            public Object doInHibernate(Session session) throws HibernateException, SQLException {
                Query query = session.createQuery("from Announcement");
                return query.list();
            }
         });
		return list;
	}	
	
	public void updateUserInfo(Login user) {
		getHibernateTemplate().update(user);
	}
}
